<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateOwnersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('owners', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('user_id')->comment('关联用户')->nullable();
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->string('image')->comment('业主图片');
            $table->string('cycle')->comment('缴费周期');
            $table->string('cycle_unit')->comment('周期单位');
            $table->decimal('cycle_price', 10, 2)->comment('每周缴费');
            $table->decimal('deposit', 10, 2)->comment('押金');
            $table->string('description')->comment('备注');
            $table->string('Contract')->comment('合同照片');
            $table->unsignedBigInteger('create_admin_id')->comment('创建人');
            $table->unsignedBigInteger('update_admin_id')->comment('更新人');
            $table->unsignedBigInteger('ownerable_id')->comment('关联id');
            $table->string('ownerable_type', 40)->comment('关联类型(house|building|room)');
            $table->dateTime('started_at')->nullable()->comment('租期开始');
            $table->dateTime('ended_at')->nullable()->comment('租期结束');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('owners');
    }
}
